package com.panshi.modules.common.tooth;

import com.panshi.api.api.TypePort;
import com.panshi.api.bean.TypeBean;
import com.panshi.api.util.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author :jiege
 * @description :
 * @create :2020-08-14 22:42:00
 */
@Controller
@Api(tags = "牙齿接口")
public class ToothController {

    @Autowired
    private TypePort typePort;


    @GetMapping("/touch/touchlist")
    @ResponseBody
    @RequiresPermissions("touch:list")
    @ApiOperation(value = "返回牙齿类型页面")
    public ModelAndView querytouchpage(){
        return new ModelAndView("/touch/touch-list");
    }


    @GetMapping("/touch/listall")
    @ResponseBody
    @RequiresPermissions("touch:list")
    @ApiOperation(value = "牙齿类型数据")
    public List<TypeBean> queryalltouch(){//查询所以类型
        return typePort.queryTypeInfoAll();
    }


    @GetMapping("/touch/listarticle")
    @ResponseBody
    @RequiresPermissions("touch:list")
    @ApiOperation(value = "文章类型数据")
    public List<TypeBean> querytoucharticle(){//咨询类型
        return typePort.queryArticleInfoAll();
    }


    @GetMapping("/touch/listanswer")
    @ResponseBody
    @RequiresPermissions("touch:list")
    @ApiOperation(value = "问答类型数据")
    public List<TypeBean> querytouchanswer(){//问答类型

        return typePort.queryAnswerInfoAll();
    }


    @PostMapping("/touch/add")
    @ResponseBody
    @RequiresPermissions("touch:add")
    @ApiOperation(value = "新增牙齿类型")
    public CommonResult<String> addtouch(TypeBean typeBean){
        typePort.addTypeInfo(typeBean);
        return new CommonResult<>();
    }

    @PostMapping("/touch/delete")
    @ResponseBody
    @RequiresPermissions("touch:delete")
    @ApiOperation(value = "删除牙齿类型")
    public CommonResult<String> deletetouch(String tid){
        typePort.deleteTypeInfo(tid);
        return new CommonResult<>();
    }

    @PostMapping("/touch/update")
    @ResponseBody
    @RequiresPermissions("touch:update")
    @ApiOperation(value = "修改牙齿类型")
    public CommonResult<String> updatetouch(TypeBean typeBean){
        typePort.updateTypeInfo(typeBean);
        return new CommonResult<>();
    }


}
